function Gadget(){
	//////////////////////////////////////
	// Loader styles
	this.showLoaderFor=function(elem){
		// Hide any errors
		this.hideError();
		Util.addClassNameTo(elem,"loading");
	};
	this.hideLoaderFor=function(elem){
		Util.removeClassNameFrom(elem,"loading");
	};
	//////////////////////////////////////
	// Error methods
	this.onError=function(){};
	this.showError=function(_msg){
		//this.stopFetchTimeout();
		Util.insertHTML("ctrError",_msg)
		Util.addClassNameTo("ctrGadget","error");
	};
	this.hideError=function(){
		Util.removeClassNameFrom("ctrGadget","error");
	};
	//////////////////////////////////////
	// Set container title
	this.setContainerTitle=function(titleStr) {
		if(_IG_SetTitle)
			_IG_SetTitle(titleStr);
	};
	//////////////////////////////////////
	// Fetch remote content
	this.fetchContent=function(contentType,url,callback,refreshCacheSeconds){
		var _self=this;
		switch(contentType){
			case "text":
				_IG_FetchContent(url,function(response){
					//_self.stopFetchTimeout();
					callback(response)
				});
			break;
			case "xml":
				if(refreshCacheSeconds){
					_IG_FetchXmlContent(url,function(response){
						_self.callBackForXmlFetch(response,callback)
					},{refreshInterval:refreshCacheSeconds});
				}
				else {
					_IG_FetchXmlContent(url,function(response){
						_self.callBackForXmlFetch(response,callback)
					});
				}
			break;
			case "json":
				_IG_FetchFeedAsJSON(url,function(response){
					_self.callBackForJsonFetch(response,callback);
				},10,true);
			break;
		}
	};
	this.callBackForJsonFetch=function(feed,callback){
		//this.stopFetchTimeout();
		if(!feed.Entry || feed==null)
			this.onError("No results found.");
		else
			callback(response);
	};
	this.callBackForXmlFetch=function(response,callback){
		//this.stopFetchTimeout();
		if(response==null || typeof(response)!="object" || response.firstChild==null)
			this.onError("Invalid data.");
		else
			callback(response);
	};
	//////////////////////////////////////
	// Resize functions
	this.resizeTo=function(height,onResized) {
		if(height)
			document.getElementById("ctrGadget").style.height=height+"px";
		window.setTimeout("_IG_AdjustIFrameHeight()",10);
		if(onResized)
			window.setTimeout(onResized,700);
	};
	this.fitToContent=function(onResized) {
		this.resizeTo(null,onResized);
	};
	//////////////////////////////////////
	// Embed flash
	this.embedFlash=function(_url,_container,_opts){
		_IG_EmbedFlash(_url,_container,_opts);
	}
	//////////////////////////////////////
	// Init Gadget object
	// - fire Gadget.onLoaded when loaded
	this.onLoaded=function(){};
	this.init=function(){
		var _self=this;
		_IG_RegisterOnloadHandler(function(){_self.onLoaded()});
	};
	this.init();
}